package com.dw.listener;

import com.dw.model.message.TestMessage;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
@Component
@RocketMQMessageListener(
        consumerGroup = "dw-consumer-group",
        topic = "topic-test",
        selectorExpression = "*",  //TAG
        consumeMode = ConsumeMode.CONCURRENTLY, //# 消费模式：CONCURRENTLY(并发)或ORDERLY(顺序)
        messageModel = MessageModel.CLUSTERING  //# 消息模式：CLUSTERING(集群)或BROADCASTING(广播)
)

public class PushConsumer implements RocketMQListener<TestMessage> {

    @Override
    public void onMessage(TestMessage message) {
        try{
        // 处理业务逻辑
            System.out.println("Consumer 接收到消息: " + message);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
